<?php 
class MY_Controller extends CI_Controller{
    public $data=array();
    function __construct(){
        parent::__construct();
         $this->load->model('m_admin');
        $uri_exception = array(
            'admin/login',
            'admin/logout'
        );
        if(in_array(uri_string(),$uri_exception)== FALSE){
            if($this->m_admin->logged_in()==FALSE){
            redirect("admin/login");
            }
        }
    }
}

?>